<script setup>
import { useRouter, useRoute } from 'vue-router'
import { useAuthStore } from '../store/auth'
import { User, Calendar, Document, Goblet, Edit, House } from '@element-plus/icons-vue'

const router = useRouter()
const route = useRoute()
const auth = useAuthStore()

const logout = () => {
  auth.logout()
  router.push('/login')
}
</script>

<template>
  <div class="layout">
    <header class="header">
      <div class="title">校医体检管理系统 - 医生端</div>
      <div class="actions">
        <el-button type="primary" text @click="router.push('/doctor/home')">首页</el-button>
        <el-dropdown>
          <span class="el-dropdown-link">{{ auth.user?.name || '医生' }}</span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item @click="router.push('/doctor/profile')">个人资料</el-dropdown-item>
              <el-dropdown-item divided @click="logout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </header>
    <div class="body">
      <aside class="sider">
        <el-menu :default-active="route.path" router>
          <el-menu-item index="/doctor/home">
            <el-icon><House /></el-icon>
            <span>首页</span>
          </el-menu-item>
          <el-menu-item index="/doctor/schedule">
            <el-icon><Calendar /></el-icon>
            <span>医生日程</span>
          </el-menu-item>
          <el-menu-item index="/doctor/orders">
            <el-icon><Document /></el-icon>
            <span>我的体检订单</span>
          </el-menu-item>
          <el-menu-item index="/doctor/samples">
            <el-icon><Goblet /></el-icon>
            <span>样本采集</span>
          </el-menu-item>
          <el-menu-item index="/doctor/indicator-results">
            <el-icon><Edit /></el-icon>
            <span>指标录入</span>
          </el-menu-item>
          <el-menu-item index="/doctor/profile">
            <el-icon><User /></el-icon>
            <span>个人资料</span>
          </el-menu-item>
        </el-menu>
      </aside>
      <main class="content">
        <router-view />
      </main>
    </div>
  </div>
}
</template>

<style scoped>
.layout { display: flex; flex-direction: column; height: 100vh; }
.header { display: flex; justify-content: space-between; align-items: center; padding: 0 16px; height: 56px; border-bottom: 1px solid #eee; }
.title { font-weight: 600; }
.body { display: flex; flex: 1; }
.sider { width: 220px; border-right: 1px solid #eee; }
.content { flex: 1; padding: 16px; overflow: auto; }
</style>